﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OthelloBoard
{
    class BoardLogic
    {
        struct Position
        {
            public sbyte x { get; set; }
            public sbyte y { get; set; }

            public Position(sbyte xpos, sbyte ypos)
                : this()
            {
                x = xpos;
                y = ypos;
            }

        }

        public bool IsLegalMove(Board b, sbyte x, sbyte y, LocationValue value)
        {
            b.CheckCoord(x);
            b.CheckCoord(y);
            if (value == LocationValue.empty) return false;
            if (b.GetLocationValue(x, y) != LocationValue.empty) return false;

            List<Position> positionsToCheck = new List<Position>();

            positionsToCheck.Add(new Position((sbyte)x, (sbyte)(y + 1)));
            positionsToCheck.Add(new Position((sbyte)x, (sbyte)(y - 1)));
            positionsToCheck.Add(new Position((sbyte)((sbyte)x + 1), (sbyte)y));
            positionsToCheck.Add(new Position((sbyte)((sbyte)x - 1), (sbyte)y));
            positionsToCheck.Add(new Position((sbyte)((sbyte)x - 1), (sbyte)(y - 1)));
            positionsToCheck.Add(new Position((sbyte)((sbyte)x + 1), (sbyte)(y + 1)));
            positionsToCheck.Add(new Position((sbyte)((sbyte)x - 1), (sbyte)(y + 1)));
            positionsToCheck.Add(new Position((sbyte)((sbyte)x + 1), (sbyte)(y - 1)));




            return true;
        }

        void Move(Board b, int x, int y, LocationValue value)
        {
            if (!IsLegalMove(b, x, y, value)) throw new Exception("Illegal move");


        }


        bool IsLocationOnBoard(Board b, int x, int y)
        {
            if ( x < 
        }
    }
}
